#include <stdio.h>

static int num[100000];

int main()
{
	int n = 0;
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ ) {
		scanf("%d", &num[i]);
	}
	
	int m = 0;
	scanf("%d", &m);
	int data = 0;
	for ( int i = 0; i < m; i++ ) {
		scanf("%d", &data);
		int minDistance = data - num[0];
		minDistance = minDistance < 0 ? -1 * minDistance : minDistance;
		int elem = num[0];
		for ( int j = 1; j < n; j++ ) {
			int distance = data - num[j];
			distance = distance < 0 ? -1 * distance : distance;
			if ( distance < minDistance ) {
				minDistance = distance;
				elem = num[j];
			}
		}
		printf("%d\n", elem);
	}
	
	return 0;
}
